receiver/httpcheck: add structured validation result metrics#48443
receiver/httpcheck: add structured validation result metrics#48443VenuEmmadi wants to merge 13 commits into
Conversation
- Add validation.target attribute to httpcheck.validation.passed and httpcheck.validation.failed metrics - Emit one datapoint per validation instead of aggregated counts - Update documentation and tests
- Add new httpcheck.validation.result metric with structured attributes: - validation.type: Type of validation (json_path, contains, regex, size, not_contains) - validation.path: The expression being evaluated - validation.expected: Expected value (when equals specified) - validation.result: Passed or failed result - Keep old httpcheck.validation.passed/failed metrics for backward compatibility - Fix per-type counting for old metrics (no longer hardcoded to json_path) - Emit one data point per validation for structured metric - Add comprehensive test TestValidationResultStructuredAttributes - Support mixed validation types (json_path, contains, regex, size) - Update README with examples and documentation
218e063 to
57f506c
Compare
- Add new httpcheck.validation.result metric with structured attributes: - validation.type: Type of validation (json_path, contains, regex, size, not_contains) - validation.path: The expression being evaluated - validation.expected: Expected value (when equals specified) - validation.result: Passed or failed result - Keep old httpcheck.validation.passed/failed metrics for backward compatibility - Fix per-type counting for old metrics (no longer hardcoded to json_path) - Emit one data point per validation for structured metric - Add comprehensive test TestValidationResultStructuredAttributes - Support mixed validation types (json_path, contains, regex, size) - Update README with examples and documentation
57f506c to
5ad48a6
Compare
| monotonic: false | ||
| unit: "{validation}" | ||
| attributes: [http.url, validation.type] | ||
| httpcheck.validation.result: |
There was a problem hiding this comment.
| httpcheck.validation.result: | |
| httpcheck.validation.outcome: |
There was a problem hiding this comment.
Thanks for the suggestion! I'd prefer to keep httpcheck.validation.result as the metric name since result is a common term in OpenTelemetry and matches existing patterns. outcome is less commonly used for validation metrics across OTel components.
There was a problem hiding this comment.
The problem is you end with an attribute in a metric with the same name which is confusing. This pattern of using outcome for the metric and result is used in semantic conventions. And In fact there is a rule for ensuring they differ: https://github.com/instrumentation-score/spec/blob/main/rules/MET-006.md
| aggregation_temporality: cumulative | ||
| monotonic: false | ||
| unit: "{validation}" | ||
| attributes: [http.url, validation.type, validation.path, validation.expected, validation.result] No newline at end of file |
There was a problem hiding this comment.
| attributes: [http.url, validation.type, validation.path, validation.expected, validation.result] | |
| attributes: [http.url, httpcheck.validation.type, httpcheck.validation.path, httpcheck. validation.expected, httpcheck.validation.result] |
There was a problem hiding this comment.
Lets Keep current names. OTel conventions typically use short, scoped names. validation.type is clear within httpcheck context.
There was a problem hiding this comment.
Actually that is not the case, the naming guidance is https://opentelemetry.io/docs/specs/semconv/general/naming/#general-naming-considerations.
Key thing is:
Be precise. Attribute, event, metric, and other names should be descriptive and unambiguous.
Note If you see an attribute validation.type you have no idea what the scope is just by looking at it hence why new attribute names are being scoped under the appropriate namespace.
Further along in that doc it mentions:
The name is specific to your application that will be used internally only. If you already have an internal company process that helps you to ensure no name clashes happen then feel free to follow it. Otherwise it is recommended to prefix the attribute name by your application name, provided that the application name is reasonably unique within your organization (e.g. myuniquemapapp.longitude is likely fine). Make sure the application name does not clash with an existing semantic convention namespace.
Which is why attributes are prefixed.
| httpcheck.validation.result: | ||
| description: Result of a response validation (1 for each validation, with result attribute). | ||
| enabled: false | ||
| stability: development | ||
| sum: | ||
| value_type: int | ||
| aggregation_temporality: cumulative | ||
| monotonic: false | ||
| unit: "{validation}" | ||
| attributes: [http.url, validation.type, validation.path, validation.expected, validation.result] No newline at end of file |
There was a problem hiding this comment.
I am wondering if we should remove validation.path & validation.expected from a metric due to cardinality & instead complement the metric with an event httpcheck.validation.failure. This event would emit that lower level detail and can add things like error.message.
There was a problem hiding this comment.
Lets Keep as is. Cardinality is safe (static config values). Events would make debugging harder for users.
There was a problem hiding this comment.
How so, adding an event would make things easier to debug as the event can contain additional attributes ie error.message?
The cardinality is higher as you end up with data points for every combination of attributes. The key thing the metric is for reporting status of the check of a http.url.
Co-authored-by: James Thompson <thompson.tomo@outlook.com>
- Add new httpcheck.validation.outcome metric with namespaced attributes - Remove deprecated passed/failed metrics (breaking change, alpha component) - Remove validation.expected attribute (cardinality risk) - One datapoint per validation rule - Add comprehensive tests and documentation
| requirement_level: recommended | ||
| network.transport: | ||
| description: OSI transport layer or inter-process communication method. | ||
| httpcheck.validation.outcome: |
There was a problem hiding this comment.
| httpcheck.validation.outcome: | |
| httpcheck.validation.result: |
Attribute should differ to metric name.
| monotonic: false | ||
| unit: "{validation}" | ||
| attributes: [http.url, validation.type] | ||
| attributes: [http.url, httpcheck.validation.type, httpcheck.validation.target, httpcheck.validation.outcome] No newline at end of file |
There was a problem hiding this comment.
| attributes: [http.url, httpcheck.validation.type, httpcheck.validation.target, httpcheck.validation.outcome] | |
| attributes: [http.url, httpcheck.validation.type, httpcheck.validation.target, httpcheck.validation.result] | |
| httpcheck.validation.failed: | ||
| description: Number of response validations that failed. | ||
| enabled: false | ||
| stability: development | ||
| sum: | ||
| value_type: int | ||
| aggregation_temporality: cumulative | ||
| monotonic: false | ||
| unit: "{validation}" | ||
| attributes: [http.url, validation.type] | ||
| httpcheck.validation.passed: | ||
| description: Number of response validations that passed. |
There was a problem hiding this comment.
Shouldn't this remain for backwards compatibility?
Description
Adds structured response validation metrics to the HTTP Check Receiver.
Problem: Previously,
httpcheck.validation.passedandhttpcheck.validation.failedonly exposed aggregated counts per validation type, making it difficult to identify which specific validation rule passed or failed when multiple validations were configured for the same endpoint.Solution: This change introduces a new metric,
httpcheck.validation.result, which emits one datapoint per validation rule.The new metric emits one datapoint per validation rule with the following structured attributes:
validation.typejson_path,contains,regex,sizevalidation.pathsystem_3,healthy,^ok$validation.expectedequalsspecified)true,ok,200validation.resultpassed,failedExample Output:
This enables users to:
Why this matters: Without this change, a user with the following API response:
{"system_1": true, "system_2": true, "system_3": false}and multiple validations would only see aggregated validation counts, without visibility into which specific validation failed. The new structured metric makes each validation independently observable.
Backward compatibility: The following legacy metrics continue to work unchanged as aggregate metrics that expose counts grouped by validation type:
httpcheck.validation.passedhttpcheck.validation.failedLink to tracking issue
Fixes #44662
Testing
Added unit tests covering:
json_pathcontainsregexsizeVerified:
validation.pathcorrectly identifies the evaluated validationvalidation.resultcorrectly reports passed/failed stateDocumentation
Updated
receiver/httpcheckreceiver/README.mdwith:httpcheck.validation.resultmetric